<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
>
<head th:lang="zh">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="login">
    <meta name="author" content="tangcheng">

    <title th:text="#{login.title}">Login</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" href="../static/css/bootstrap.min.css">
    <link rel="stylesheet" th:href="@{/css/signin.css}" href="../static/css/signin.css">
</head>
<body>
<div class="container">
    <!--${param.x} 返回requeast的参数x（可以为复合值）-->
    <div th:if="${param.logout}" class="container text-center alert-success">You have been logged out!</div>
    <div th:if="${param.error}" class="container text-center  alert-warning">
        Username and password not matched, please try again!
    </div>
    <div th:if="${param.code}" class="container text-center  alert-warning">
        captcha code not matched, please try again!
    </div>

    <form class="form-signin" th:action="@{/login}" action="/login" method="POST">
        <h2 class="form-signin-heading">Please sign in</h2>
        <input type="text" id="username" class="form-control" name="username"
               placeholder="Username" required/>
        <input type="password" id="password" class="form-control" name="password"
               placeholder="Password" required/>
        <div class="form-group form-horizontal">
            <div class="row">
                <div class="col-md-8">
                    <input type="text" class="form-control" name="code" placeholder="Security code" required/>
                </div>
                <div class="col-md-4">
                    <img class="img-responsive" src="/captcha.jpg" id="captcha"/>
                </div>

            </div>
        </div>
        <div class="checkbox">
            <label>
                <input type="checkbox" name="remember-me">Remember me
            </label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
    </form>
</div>
<!-- /container -->

</body>
<script th:src=" @{/js/jquery-3.2.1.min.js}" src="../static/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    $(function () { //生成验证码
        $('#captcha').click(function () {
            $(this).hide().attr('src', '/captcha.jpg?' + Math.floor(Math.random() * 10000)).fadeIn();
        });
    });

    function changeCode() { //刷新
        $('#captcha').hide().attr('src', '/captcha.jpg?' + Math.floor(Math.random() * 10000)).fadeIn();
        event.cancelBubble = true;
    }
</script>
</html>